package com.saber.pattern.singleton;

/**
 * 由于内部类的特性， 线程安全。
 * @author saber
 * @version 1.0
 * @Package: com.saber.pattern.singleton
 * @Date: 2017/4/10
 * @Time: 13:37
 */
public class SingletonInnerClass {

    private SingletonInnerClass instance = null;

    public SingletonInnerClass getInstance() {
        if (null == instance) {
            instance = SingletonInnerClass.InnerClass.init();
        }
        return instance;
    }

    private static class InnerClass {
        public static SingletonInnerClass init() {
            return new SingletonInnerClass();
        }
    }

}
